package 力扣._00周赛._430周赛.问题1;

import java.util.Arrays;

class Solution {
    public int minimumOperations(int[][] grid) {
        int count = 0;
        // 让所有列严格递增
        for (int j = 0; j < grid[0].length; j++) {
            for (int i = 1; i < grid.length; i++) {
                if (grid[i][j] <= grid[i-1][j]) {
                    count += grid[i-1][j] - grid[i][j] + 1;
                    grid[i][j] = grid[i-1][j] + 1;
                }
            }
        }
        for (int i = 0; i < grid.length; i++) {
            System.out.println(Arrays.toString(grid[i]));
        }
        return count;
    }

    public static void main(String[] args) {
        Solution s = new Solution();
        // [[3,2],[1,3],[3,4],[0,1]]
        int[][] grid = new int[][]{{3, 2}, {1, 3}, {3, 4}, {0, 1}};
        System.out.println(s.minimumOperations(grid));
    }
}